import R from 'ramda'

export const resolvePath = R.unless(
    R.startsWith('/'),
    R.curryN(2, R.concat)('/')
)

export const changeToArr = R.unless(
    R.is(Array),
    R.of
)

export const convert = middleware => (target, key, descriptor) => {
    target[key] = R.compose(
        R.concat(
            changeToArr(middleware)
        ),
        changeToArr
    )(target[key])
    return descriptor
}
